package cn.net.autocode.platform.providers;

import com.alibaba.fastjson2.JSONObject;
import cn.net.autocode.platform.providers.service.SaveServ;
import cn.net.autocode.core.bean.ResultT;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("autocode/saveProvider")
public class SaveProviderCtrl extends ProviderCtrl{

    private final SaveServ saveServ;

    public SaveProviderCtrl(SaveServ saveServ) {
        this.saveServ = saveServ;
    }

    @RequestMapping("{tableCode}")
    @Transactional
    public ResultT execute(@PathVariable("tableCode") String tableCode, @RequestBody JSONObject data){
        saveServ.saveByTableCode(tableCode,data);
        return ResultT.success(data);
    }

}
